#pragma once
#include <iostream>
#include <string>
#include <ctime>


#define INFO 1 
#define WARNING 2 
#define ERROR 3 
#define FATAL 4

#define LOG(level, message) log(#level, message, __FILE__, __LINE__) 


static const std::string  log_file_name = "log" ;

void log(std::string level, std::string message , std::string file_name, int where_line)
{

//#ifdef DEBUG 

    std::cout << "[" << level << "]" 
    << "[ time: " <<time(nullptr) << "]" 
    << "[file_name: " << file_name << "]"  
    << "[line: " << where_line << "]"
    "[message: " << message  << "]" << std::endl ;
//# elif DAEMOND
    
    // 将日志信息输入到文件中去

    std::string total_message = "[" + level + "]" 
    + "[ time: " + std::to_string(time(nullptr)) + "]" 
    + "[file_name: " + file_name + "]"  
    + "[line: " + std::to_string(where_line) + "]"
    "[message: " + message  + "]" ;


    FILE* fp = fopen(log_file_name.c_str(), "a") ;
    fprintf(fp, "%s\n",  total_message.c_str()) ;  
    fclose(fp)  ; 


//# endif 
}

